package org.spal.cliente

import org.spal.Local;
import org.springframework.dao.DataIntegrityViolationException

class LocalClienteController {

    def index() {
        redirect(action: "locales", params: params)
    }
	
	def locales() {
		render(view: "/cliente/local/locales", model: [locales: Local.findAllByHabilitado(true), localInstanceTotal: Local.count()])
	}
	
	def displayImage() {
		def img = Local.get(params.id).foto
		response.setHeader('Content-length', img.length)
		response.contentType = 'image/jpg' // or the appropriate image content type
		response.outputStream << img
		response.outputStream.flush()
	}
	
	def displayImg = {
		def local = Local.get(params.id)
		response.contentType = "image/jpg"
		response.contentLength = local?.foto.length
		response.outputStream.write(local?.foto)
	}

}
